/**
 * fileName: ConnectionDBUtil.java
 *     Date: 2012-4-29
 **/
package com.stranger.common.util;

import java.sql.Connection;
import java.sql.DriverManager;

/**
 * @作者 stranger.lin
 *
 * @时间 2012-4-29
 */
public class ConnectionDBUtil {
	
	private static String driver="com.mysql.jdbc.Driver";
	private static String url="jdbc:mysql://192.168.10.10/smsdbsms?useUnicode=true&amp;charset=utf-8";
	private static String userName="smsroot";
	private static String password="smsroot";
	private static Connection conn=null;
	
	public static Connection getConnection(){
		try {
			if (conn==null) {
				Class.forName(driver);
				conn=DriverManager.getConnection(url, userName, password);
			}
			System.err.println("数据库连接成功");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return conn;
		
	}
	public static void main(String[] args) {
		ConnectionDBUtil.getConnection();
	}

}
